package com.unione.map.view.fragment

import android.view.LayoutInflater
import android.view.View
import android.view.View.OnClickListener
import android.view.ViewGroup
import androidx.navigation.Navigation
import com.unione.map.R
import com.unione.map.databinding.FragmentMainBinding
import com.unione.map.view.act.MainActivity

class MainFragment : AppBaseFragment<FragmentMainBinding>(), OnClickListener {


    override fun onCreateViewBinding(
        inflater: LayoutInflater,
        parent: ViewGroup?
    ): FragmentMainBinding {
        return FragmentMainBinding.inflate(inflater, parent, false)
    }

    override fun init() {
        initView()
        initListeners()
    }

    private fun initView() {
        binding.tvExit.setOnClickListener(this)
        binding.tvVoice.setOnClickListener(this)
        binding.clCreateMap.setOnClickListener(this)
        binding.clEditMap.setOnClickListener(this)
        binding.clBaseSetting.setOnClickListener(this)
        binding.clFuncTest.setOnClickListener(this)
    }

    private fun initListeners() {

    }

    override fun onClick(v: View?) {
        super.onClick(v)
        if (v == null) return
        val nvController =
            Navigation.findNavController(
                requireActivity() as MainActivity,
                R.id.fragment_container_view
            )
        when (v.id) {
            R.id.tvExit -> {}
            R.id.tvVoice -> {}
            R.id.clCreateMap -> {
                nvController.navigate(R.id.createMapStep1Fragment)
            }

            R.id.clEditMap -> {
                nvController.navigate(R.id.editMapStep1Fragment)
            }

            R.id.clBaseSetting -> {}
            R.id.clFuncTest -> {}
        }
    }
}